package Recursion;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * Created by sunwei on 2017/10/12
 * Time:14:45
 */
public class Triangle {
    static int theNumber;

    public static void main(String[] args) throws IOException {
        System.out.print("Enter a number:");
        theNumber=getInt();
        int theAnswer= trangle(theNumber);
        System.out.println("Trangle="+theAnswer);
    }
    public static int trangle(int n){
        if (n==1) {
              return 1;
        }  else {
            return (n+trangle(n-1));
        }
    }
    public static String getString() throws IOException{
        InputStreamReader inputStreamReader = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(inputStreamReader);
        String s = br.readLine();
        return s;
    }
    public static int getInt() throws IOException{
        String s = getString();
        return Integer.parseInt(s);
    }
}
